package com.launcher.decorator;

import javax.persistence.Entity;
import javax.persistence.OneToOne;

import com.launcher.PayLoad;
import com.launcher.Rocket;

@Entity
public class RocketTop extends RocketDecorator
{
	@OneToOne
	private PayLoad payload;
	
	public RocketTop()
	{
		super(null);
	}
	
	public RocketTop(Rocket decoratedRocket, PayLoad payload)
	{
		super(decoratedRocket);
		this.payload = payload;
	}
	
	@Override
	public int getTotalCost()
	{
		return decoratedRocket.getTotalCost() + payload.getCost() + getCost();
	}

	@Override
	public int getTotalMass()
	{
		return decoratedRocket.getTotalMass() + payload.getMass() + getMass();
	}

	@Override
	public String getParts()
	{
		return super.getParts() + " with payload: " + payload.getMass();
	}
	
	public PayLoad getPayLoad()
	{
		return payload;
	}
	
	public RocketTop clone()
	{
		RocketTop top = new RocketTop(null, getPayLoad());
		top.setCost(getCost());
		top.setMass(getMass());
		
		return top;
	}
}
